package com.loup.session;

import com.loup.configure.LoupConfiguration;
import com.loup.executor.Executor;
import com.loup.executor.LoupExecutor;
import com.loup.proxy.LoupMapperProxy;

import java.lang.reflect.Proxy;

/**
 * Created by loup on 2018/4/26.
 */
public class DefaultLoupSqlSession implements LoupSqlSession{

    private LoupConfiguration configuration;
    private Executor executor;

    public DefaultLoupSqlSession(LoupConfiguration configuration, Executor executor) {
        this.configuration = configuration;
        this.executor = executor;
    }

    public <T> T getMapper(Class<T> clazz){
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(),new Class[]{clazz},new LoupMapperProxy(this));
    }

    public <T> T selectOne(String statement,String param,Class clazz){
        return executor.query(statement,param,clazz);
    }

    public LoupSqlSession openSqlSession(){
        return null;
    }
}
